import 'package:flutter/material.dart';
import 'package:flutter_app/components/radiusContainer.dart';
import 'package:flutter_app/components/layout.dart';
import 'package:flutter_app/generated/l10n.dart';
class InvestRecordPage extends StatefulWidget {
  @override
  _InvestRecordPageState createState() => _InvestRecordPageState();
}

class ListItem {
  String name;
  String url;
  String icon;

  ListItem({this.name, this.url, this.icon});
}


Widget getItemContainer(context,item) {
  return GestureDetector(
      onTap: () => Navigator.pushNamed(context, item.url),
      child: RadiusContainer(
          radius: 10.0,
          margin: EdgeInsets.only(bottom: 15),
          child: Row(
            children: [
              Image.asset(
                item.icon,
                width: 50,
              ),
              SizedBox(
                width: 15,
              ),
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    item.name,
                    style: TextStyle(fontSize: 16, fontFamily: 'dinpro'),
                  ),
                  SizedBox(
                    height: 5,
                  ),
                  //无在持投资
                  Text(
                    S.of(context).no_invest,
                    style: TextStyle(color: Colors.grey, fontFamily: 'dinpro'),
                  ),
                ],
              ),
            ],
          )));
}

class _InvestRecordPageState extends State<InvestRecordPage> {
  @override
  Widget build(BuildContext context) {
    List<ListItem> LIST_ITEMS = [
      ListItem(
          name: S.of(context).dual_coin('BTC'),
          url: "/double/record",
          icon: 'assets/images/ic_product_list_dual_ccy_btc.png'),
      ListItem(
          name: S.of(context).dual_coin('BTC-U'),
          url: '/double/record',
          icon: 'assets/images/ic_product_list_dual_ccy_usd.png'),
      ListItem(
          name: S.of(context).dual_coin('ETH'),
          url: '/double/record',
          icon: 'assets/images/ic_product_list_dual_ccy_eth.png'),
      ListItem(
          name: S.of(context).dual_coin('ETH-U'),
          url: '/double/record',
          icon: 'assets/images/ic_product_list_dual_ccy_eth_usd.png'),
      ListItem(
        name:  S.of(context).dual_coin('BCH'),
        url: '/double/record',
        icon: 'assets/images/ic_product_list_dual_ccy_bch.png',
      ),
      ListItem(
        name:  S.of(context).dual_coin('BCH-U'),
        url: '/double/record',
        icon: 'assets/images/ic_product_list_dual_ccy_usd.png',
      ),
      ListItem(
        name: 'DeFi',
        url: '',
        icon: 'assets/images/ic_product_list_wealth.png',
      ),
      ListItem(
        name: S.of(context).featured,
        url: '',
        icon: 'assets/images/ic_product_list_featured.png',
      )
    ];
    List<Widget> getItems(context) {
      var Newlist = LIST_ITEMS.skip(1).toList();
      return Newlist.map((item) => getItemContainer(context,item)).toList();
    }
    return Scaffold(
      appBar: AppBar(
        brightness: Brightness.dark,
        backgroundColor: Color(0xFF3D6CFF),
        elevation: 0,
        //invest_record 投资记录
        title: HeadTitle(S.of(context).invest_record),
        centerTitle: true,
      ),
      body: Container(
        color: Color(0xFFF4F7FF),
        child: RefreshIndicator(
          onRefresh: () async {},
          child: SingleChildScrollView(
            child: Column(
              children: [
                Container(
                  height: 150,
                  child: Stack(
                    children: [
                      //在持投资
                      Positioned(
                        top: 0,
                        left: 0,
                        right: 0,
                        child: Container(
                          height: 100,
                          color: Color(0xFF3D6CFF),
                          alignment: Alignment.center,
                          child: Column(
                            children: [
                              SizedBox(
                                height: 10,
                              ),
                              //无在持投资
                              Text(
                                S.of(context).no_invest,
                                style: TextStyle(
                                    color: Color(0xFF7FC0FF), fontSize: 16),
                              ),
                            ],
                          ),
                        ),
                      ),
                      Positioned(
                        top: 60,
                        left: 0,
                        right: 0,
                        child: Padding(
                            padding: EdgeInsets.symmetric(horizontal: 15.0),
                            child: getItemContainer(context,LIST_ITEMS[0])),
                      )
                    ],
                  ),
                ),
                Padding(
                  padding: EdgeInsets.symmetric(horizontal: 15.0),
                  child: Column(children: getItems(context)),
                )
              ],
            ),
          ),
        ),
      ),
    );
  }
}
